<template>
  <div class="user">
    <el-form
      :label-position="labelPosition"
      label-width="80px"
      :model="formLabelAlign"
    >
      <el-form-item>
        <div class="imgBox">
          <img src="./../../assets/saber.jpg" alt="" width="40" />
        </div>
      </el-form-item>
      <el-form-item label="姓名">
        <el-input v-model="formLabelAlign.name"></el-input>
      </el-form-item>
      <el-form-item label="手机号">
        <el-input v-model="formLabelAlign.phone"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button class="logOutBtn" @click="logOut">退出</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      labelPosition: "right",
      formLabelAlign: {
        name: "Annie",
        phone: "156xxxx3196",
      },
    };
  },
  methods: {
    async logOut() {
      let data = await this.$axios.get("/users/logout");
      console.log(data);
      if (data.code === 0) {
        this.$store.commit("login/LOGIN_FLAG", { isLogin: false });
        window.localStorage.removeItem("user");
      }
      this.$router.push("/mine/login");
    },
  },
};
</script>

<style scoped>
.imgBox {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
}
</style>